package com.File_io_.io_.OutputStream;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * @author 宋鑫宇
 * @version 1.0
 * 使用 BufferedInputStream 和 BufferedOutputStream 拷贝二进制文件
 */
public class BufferedOutputStreamCopy {
    public static void main(String[] args) throws Exception{
//        BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream("C:\\Users\\Administrator\\Pictures\\1.jpg"));
//        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream("D:\\idea_WorkSpace\\myjava\\myjava\\src\\com\\File_io_\\date\\1.jpg"));
        BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream("D:\\idea_WorkSpace\\myjava\\myjava\\src\\com\\File_io_\\hello.txt"));
        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream("D:\\idea_WorkSpace\\myjava\\myjava\\src\\com\\File_io_\\date\\hello.txt"));
        byte[] a = new byte[1024];
        int len = 0;
        while ((len = bufferedInputStream.read(a)) != -1){
            bufferedOutputStream.write(a,0,len);
        }
        bufferedInputStream.close();
        bufferedOutputStream.close();

    }
}
